#!/bin/bash

echo "clean up ..."
mount /dev/sdb3 /mnt/sys
rm -rf /mnt/sys/*
umount /mnt/sys

mount /dev/sdb2 /mnt/sys
rm -rf /mnt/sys/*
umount /mnt/sys

mount /dev/sdb4 /mnt/sys
rm -rf /mnt/sys/*
umount /mnt/sys

echo "mount usb ..."
mount /dev/sdb4 /mnt/sys/
mkdir /mnt/sys/boot
mount /dev/sdb2 /mnt/sys/boot/
mkdir /mnt/sys/boot/efi
mount /dev/sdb3 /mnt/sys/boot/efi/

echo "sync tarball ..."
pushd /mnt/sys
tar xpf /opt/clfs/loongarch64-clfs-system-2025.9.tar.bz2
popd

echo "create grub menu ..."
read -p "please execute 031-make-grub-menu.sh, then press any key to continue ..."

echo "umount usb ..."
umount -R /mnt/sys


